/*
 * Mypanel2.java
 *
 * Created on May 18, 2006, 6:56 PM
 */

/**
 *
 * @author  iman
 */
import java.lang.System.*;
import java.io.File.*;
import javax.swing.*;
import java.io.*;
import java.awt.*;
public class MyButtonWizardPanel1 extends javax.swing.JPanel {
    public int flagBack=0,text=1,image=0;
     public MyButtonWizardFrame frame;
     public JButton button;
    public String name,tname;
    public String  choice;
    /** Creates new form Mypanel2 */
     public MyButtonWizardPanel1(MyButtonWizardFrame frame)  {
        this.frame=frame;
        setLayout(new FlowLayout());
         //jList1.setSelectedIndex(0);
        initComponents();
        ButtonGroup buttonGroup=new ButtonGroup ();
        buttonGroup.add(jRadioButton1);
        buttonGroup.add(jRadioButton2);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jSeparator1 = new javax.swing.JSeparator();
        jButton3 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jRadioButton1 = new javax.swing.JRadioButton();
        jRadioButton2 = new javax.swing.JRadioButton();
        jButton1 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel4 = new javax.swing.JLabel();
        jSeparator3 = new javax.swing.JSeparator();

        jButton3.setText("< Back");
        jButton5.setText("Finish");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton2.setText("Cancel");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton4.setText("Next >");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jLabel1.setText("Do you Want text or a picture on the button?");

        jLabel2.setText(" If you choose a text, you can type the text to display.");

        jLabel3.setText("If you choose a picture you can click browse");

        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });
        jTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextField1KeyReleased(evt);
            }
        });

        jRadioButton1.setSelected(true);
        jRadioButton1.setText("  Text :");
        jRadioButton1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jRadioButton1.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton1ActionPerformed(evt);
            }
        });
        jRadioButton1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jRadioButton1StateChanged(evt);
            }
        });

        jRadioButton2.setText("   Picture:");
        jRadioButton2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jRadioButton2.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton2ActionPerformed(evt);
            }
        });
        jRadioButton2.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jRadioButton2StateChanged(evt);
            }
        });

        jButton1.setText("Browse");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton6.setText("Cancel");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jButton7.setText("< Back");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jButton8.setText("Next >");
        jButton8.setEnabled(false);
        jButton8.setMaximumSize(new java.awt.Dimension(65, 23));
        jButton8.setMinimumSize(new java.awt.Dimension(65, 23));
        jButton8.setPreferredSize(new java.awt.Dimension(65, 23));
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        jButton9.setText("Finish");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        jList1.setAutoscrolls(false);
        jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jList1ValueChanged(evt);
            }
        });
        jList1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jList1MouseClicked(evt);
            }
        });

        jScrollPane1.setViewportView(jList1);

        jLabel4.setText("Sample:");

        jSeparator3.setOrientation(javax.swing.SwingConstants.VERTICAL);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 331, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 378, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(layout.createSequentialGroup()
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jRadioButton1)
                                    .add(jRadioButton2))
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(layout.createSequentialGroup()
                                        .add(7, 7, 7)
                                        .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 210, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                    .add(layout.createSequentialGroup()
                                        .add(19, 19, 19)
                                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 144, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(jButton1))))
                            .add(jLabel2))
                        .add(81, 81, 81)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jSeparator3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 104, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                        .addContainerGap()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, jSeparator2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
                            .add(layout.createSequentialGroup()
                                .add(jButton6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 78, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 79, Short.MAX_VALUE)
                                .add(jButton7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 89, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(jButton8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(jButton9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                        .add(215, 215, 215)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel1)
                    .add(jLabel4))
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel3)
                        .add(23, 23, 23)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jRadioButton1)
                            .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(23, 23, 23)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jRadioButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 32, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(30, 30, 30)
                        .add(jSeparator2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jButton6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 29, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jButton7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 31, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jButton8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 31, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jButton9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(layout.createSequentialGroup()
                        .add(21, 21, 21)
                        .add(jSeparator3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 202, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked
                switch(frame.operation)
               {
                   case 1: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Find Next.png"; break;
                   case 2: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Find Record.png"; break;
                   case 3: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Go To First.png"; break;
                   case 4: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Go To Last.png"; break;
                   case 5: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Go To Next.png"; break;
                   case 6: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Go To Previous.png"; break;
                   case 7: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Add New Record.png"; break;
                   case 8: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Delete Record.png"; break;
                   case 9: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Duplicate Record.png"; break;
                   case 10: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Print.png"; break;
                   case 11: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Save Record.png"; break;
                   case 12: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Undo Record.png"; break;
                   case 13: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Apply Form Filter.png"; break;
                   case 14: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Close Form.png"; break;
                   case 15: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Open Form.png"; break;
                   case 16: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Print.png"; break;
                   case 17: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Refresh.png"; break;
               }
             jRadioButton1.setSelected(false);
             jRadioButton2.setSelected(true);
             jRadioButton2.setEnabled(true);
             button.setText("");
             button.setIcon(new ImageIcon(name));
             text=0;
             image=1;
    }//GEN-LAST:event_jList1MouseClicked

    private void jTextField1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField1KeyReleased
                  tname=jTextField1.getText();// TODO add your handling code here:
                  button.setIcon(null);
                  button.setText(jTextField1.getText());
                   jRadioButton1.setSelected(true);
                   jRadioButton1.setEnabled(true);
                    jRadioButton2.setSelected(false);
                  text=1;
                  image=0;
    }//GEN-LAST:event_jTextField1KeyReleased

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
    }//GEN-LAST:event_jTextField1ActionPerformed

    private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jList1ValueChanged
                switch(frame.operation)
               {
                   case 1: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Find Next.png"; break;
                   case 2: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Find Record.png"; break;
                   case 3: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Go To First.png"; break;
                   case 4: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Go To Last.png"; break;
                   case 5: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Go To Next.png"; break;
                   case 6: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Go To Previous.png"; break;
                   case 7: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Add New Record.png"; break;
                   case 8: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Delete Record.png"; break;
                   case 9: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Duplicate Record.png"; break;
                   case 10: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Print.png"; break;
                   case 11: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Save Record.png"; break;
                   case 12: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Undo Record.png"; break;
                   case 13: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Apply Form Filter.png"; break;
                   case 14: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Close Form.png"; break;
                   case 15: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Open Form.png"; break;
                   case 16: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Print.png"; break;
                   case 17: name="C://Documents and Settings//iman//Desktop//MySQLFormBuilder//Images//Refresh.png"; break;
               }
             jRadioButton1.setSelected(false);
             jRadioButton2.setSelected(true);
             jRadioButton2.setEnabled(true);
             button.setText("");
             button.setIcon(new ImageIcon(name));
             text=0;
             image=1;
    }//GEN-LAST:event_jList1ValueChanged

    private void jRadioButton1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jRadioButton1StateChanged
    }//GEN-LAST:event_jRadioButton1StateChanged

    private void jRadioButton2StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jRadioButton2StateChanged
    }//GEN-LAST:event_jRadioButton2StateChanged

    private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton2ActionPerformed
            
            if(image==0){image=1;text=0;}
             else{image=0;text=1;}
             
             
    }//GEN-LAST:event_jRadioButton2ActionPerformed

    private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton1ActionPerformed
         button.setIcon(null);
         button.setText(jTextField1.getText());    
        if(text==0){text=1;}
            else{text=0;}
    }//GEN-LAST:event_jRadioButton1ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        MyPictureChooser filechooser=new MyPictureChooser(frame);
        File f=filechooser.getSelectedFile();
        if (f != null)
        {
        name=f.toString();
          jRadioButton1.setSelected(false);
             jRadioButton2.setSelected(true);
             jRadioButton2.setEnabled(true);
             button.setText("");
             button.setIcon(new ImageIcon(name));
             text=0;
             image=1;
         }
        
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
             
                flagBack=1;
               
                 frame.remove(this);
                 frame.add(frame.jPanel1);
                 frame.add(frame.jPanel2);
                 frame.validate();
                 frame.repaint();
                 
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
         if(text==1) {
             tname=jTextField1.getText();
           frame.finish(tname, null);
       } else {
           frame.finish(null, new ImageIcon(name));
       }                     
       frame.dispose();      
     
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
       
        frame.dispose();
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
    }//GEN-LAST:event_jButton4ActionPerformed

    
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    }//GEN-LAST:event_jButton2ActionPerformed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    public javax.swing.JList jList1;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JRadioButton jRadioButton2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    public javax.swing.JTextField jTextField1;
    // End of variables declaration//GEN-END:variables
    
}
